package cpe.hapa.model;

import java.text.DecimalFormat;
import java.util.Date;

import com.google.apphosting.api.DeadlineExceededException;


public class Vol {
	private String leavingFrom;
	private String goingTo;
	private Date departureDate;
	private Date arrivalDate;
	private String departureTime;
	private String arrivalTime;
	private double price;
	private int availableSeats;
	private String duration;
	
	public Vol(String leavingFrom, String goingTo, Date departureDate, Date arrivalDate, String departureTime, String arrivalTime, double price, int availableSeats)
	{
		super();
		this.arrivalDate = arrivalDate;
		this.arrivalTime = arrivalTime;
		this.availableSeats = availableSeats;
		this.departureDate = departureDate;
		this.departureTime = departureTime;
		this.goingTo = goingTo;
		this.leavingFrom = leavingFrom;
		this.price = price;
		
		String[] arrival = arrivalTime.split(":");
		String[] departure = departureTime.split(":");
		long minutes = (arrivalDate.getTime() - departureDate.getTime())/(60*1000) + Integer.parseInt(arrival[0])*60 + Integer.parseInt(arrival[1]) - Integer.parseInt(departure[0])*60 - Integer.parseInt(departure[1]);
		long heure = (long)minutes/60;
		long minute = minutes - heure*60;
		
		this.duration = heure + "h" + minute;
	}
	
	
	private double getTimeDifference(String arrivalTime2, String departureTime2) {
		String[] arrival = arrivalTime2.split(":");
		String[] departure = departureTime2.split(":");
		
		return (double)(Integer.parseInt(arrival[0])*60 + Integer.parseInt(arrival[1]) - Integer.parseInt(departure[0])*60 - Integer.parseInt(departure[1]))/60;
	}


	public String getDuration() {
		return duration;
	}


	public void setDuration(String duration) {
		this.duration = duration;
	}


	public String getDepartureTime() {
		return departureTime;
	}
	public String getArrivalTime() {
		return arrivalTime;
	}
	public Date getDepartureDate() {
		return departureDate;
	}
	public void setDepartureDate(Date departureDate) {
		this.departureDate = departureDate;
	}
	public Date getArrivalDate() {
		return arrivalDate;
	}
	public void setArrivalDate(Date arrivalDate) {
		this.arrivalDate = arrivalDate;
	}
	public void setDepartureTime(String departureTime) {
		this.departureTime = departureTime;
	}
	public void setArrivalTime(String arrivalTime) {
		this.arrivalTime = arrivalTime;
	}
	public String getLeavingFrom() {
		return leavingFrom;
	}
	public void setLeavingFrom(String leavingFrom) {
		this.leavingFrom = leavingFrom;
	}
	public String getGoingTo() {
		return goingTo;
	}
	public void setGoingTo(String goingTo) {
		this.goingTo = goingTo;
	}
	public double getPrice() {
		return price;
	}
	public void setPrice(double price) {
		this.price = price;
	}
	public int getAvailableSeats() {
		return availableSeats;
	}
	public void setAvailableSeats(int availableSeats) {
		this.availableSeats = availableSeats;
	}
	
	
}
